package com.pym.service.impl;

import com.pym.entity.PymUploadPhoto;
import com.pym.dao.PymUploadPhotoDao;
import com.pym.service.PymUploadPhotoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * 上传照片表(PymUploadPhoto)表服务实现类
 *
 * @author makejava
 * @since 2021-08-20 19:47:13
 */
@Service
public class PymUploadPhotoServiceImpl implements PymUploadPhotoService {
    @Autowired
    private PymUploadPhotoDao pymUploadPhotoDao;

    /**
     * 通过ID查询单条数据
     *
     * @param id 主键
     * @return 实例对象
     */
    @Override
    public PymUploadPhoto queryById(String id) {
        return this.pymUploadPhotoDao.queryById(id);
    }

    /**
     * 查询多条数据
     *
     * @param offset 查询起始位置
     * @param limit  查询条数
     * @return 对象列表
     */
    @Override
    public List<PymUploadPhoto> queryAllByLimit(int offset, int limit) {
        return this.pymUploadPhotoDao.queryAllByLimit(offset, limit);
    }

    /**
     * 新增数据
     *
     * @param pymUploadPhoto 实例对象
     * @return 实例对象
     */
    @Override
    public PymUploadPhoto insert(PymUploadPhoto pymUploadPhoto) {
        this.pymUploadPhotoDao.insert(pymUploadPhoto);
        return pymUploadPhoto;
    }

    /**
     * 修改数据
     *
     * @param pymUploadPhoto 实例对象
     * @return 实例对象
     */
    @Override
    public PymUploadPhoto update(PymUploadPhoto pymUploadPhoto) {
        this.pymUploadPhotoDao.update(pymUploadPhoto);
        return this.queryById(pymUploadPhoto.getId());
    }

    /**
     * 通过主键删除数据
     *
     * @param id 主键
     * @return 是否成功
     */
    @Override
    public boolean deleteById(String id) {
        return this.pymUploadPhotoDao.deleteById(id) > 0;
    }
}
